//
//  Song.m
//  MyKara
//
//  Created by Buffalo on 1/28/15.
//  Copyright (c) 2015 Buffalo. All rights reserved.
//

#import "Song.h"
#import "AppDefine.h"
#import "AppUtils.h"
@implementation Song

- (id)initSongInArray:(NSArray *)songList atIndex:(NSInteger)index {
    self = [super init];
    if (self) {
        NSDictionary *song = [songList objectAtIndex:index];
        self.name = [[song objectForKey:KEY_SONG_NAME] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        self.code = [song objectForKey:KEY_SONG_CODE];
        self.singerId = [song objectForKey:KEY_SINGER_ID];
        self.lyrics = [song objectForKey:KEY_SONG_LYRICS];
        self.like = [AppUtils getLikeStatusWithSongCode:self.code];
    }
    return self;
}

- (id)initSongWithCode:(NSString *)songCode {
    self = [super init];
    if (self) {
        NSDictionary *song = [NSDictionary dictionaryWithDictionary:[AppUtils getSongWithCode:songCode]];
        self.name = [[song objectForKey:KEY_SONG_NAME] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        self.code = [song objectForKey:KEY_SONG_CODE];
        self.singerId = [song objectForKey:KEY_SINGER_ID];
        self.lyrics = [song objectForKey:KEY_SONG_LYRICS];
        self.like = [AppUtils getLikeStatusWithSongCode:self.code];
    }
    return self;
}
@end
